home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
pcr
/
pcr4_4.lha
/
DIST
/
debugnub
/
CirioNubInnerProcs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-16
|
8KB
|
310 lines
/* begincopyright
Copyright (c) 1988-1992 Xerox Corporation. All rights reserved.
Use and copying of this software and preparation of derivative works based
upon this software are permitted. Any distribution of this software or
derivative works must comply with all applicable United States export
control laws. This software is made available AS IS, and Xerox Corporation
makes no warranty about the software, its performance or its conformity to
any specification. Any person obtaining a copy of this software is requested
to send their name and post office or electronic mail address to:
PCR Coordinator
Xerox PARC
3333 Coyote Hill Rd.
Palo Alto, CA 94304
endcopyright */
/*
* CirioNubInnerProcs.c
*
* Demers, February 25, 1992 11:40:39 am PST
*
* Utilities shared between local and server procs.
* Never lock the load state.
*/
#include "xr/Errno.h"
#include "xr/Threads.h"
#include "xr/ThreadsBackdoor.h"
#include "xr/IncrementalLoad.h"
#include "xr/CirioNubInnerProcs.h"
int
CirioNubInnerGetThread(index, buf)
int index;
CirioNubThreadData buf;
{
XR_Thread t;
int realIndex;
realIndex = ((index >= 0) ? index : (-index));
if( realIndex >= XR_maxThreads ) return (-1);
t = &(XR_sysArea->sa_threadPool[realIndex]);
if( (t->t_sStat <= XR_SSTAT_FREE) && (index >= 0) ) return(-1);
buf->cntd_index = realIndex;
buf->cntd_gen = t->t_gen;
buf->cntd_sStat = t->t_sStat;
buf->cntd_pri = t->t_pri;
buf->cntd_dbMsg = t->t_dbMsg;
buf->cntd_dbFrozen = t->t_dbFrozen;
buf->cntd_pc = XR_SAVED_PC(t);
buf->cntd_fp = NIL; buf->cntd_sp = NIL;
XR_GET_SAVED_FRAME(t,(buf->cntd_fp),(buf->cntd_sp));
return 0;
}
/*
* "Real Name" heuristic -- because we generate lots of ugly names
* of the form "cedarCc47From31415926.c2c.o"
*/
static bool
LooksLikeRealName(name)
char *name;
{
int digitRun = 0;
# define MAXDIGITRUNINREALNAME 5
char c;
if( name == NIL ) return FALSE;
for(;;) {
if( (c = *name++) == 0 ) return TRUE;
if( (c >= '0') && (c <= '9') ) {
if( ++digitRun > MAXDIGITRUNINREALNAME ) return FALSE;
} else {
digitRun = 0;
}
}
}
static XR_ILSymEntry
CirioNubInnerImproveEmbeddedFileNameGuess(ilseFN)
XR_ILSymEntry ilseFN;
{
XR_ILSymEntry ilseTemp = ilseFN;
for(;;) {
if( LooksLikeRealName(ilseTemp->ilse_name) ) return ilseTemp;
ilseTemp = XR_ILGetMatchingSymEntryByValue(
/*prev ilse*/ ilseTemp,
/*value*/ 0, /*ignored*/
/*wantedTypes*/ ILSE_MODULE,
/*ignoredClasses*/ IGNORE_NONE,
/*numToSkip*/ (-1)
);
if( (ilseTemp == NIL)
|| (ilseTemp->ilse_value != ilseFN->ilse_value) ) {
return ilseFN;
}
}
}
int
CirioNubInnerPCtoInfo(pc, buf)
XR_Pointer pc;
CirioNubPCInfo buf;
{
XR_ILSymEntry ilse;
unsigned argValue;
XR_ILSymEntry ilseProc = NIL;
XR_ILSymEntry ilseFN = NIL;
XR_ILFileEntry ilfe = NIL;
ilse = XR_ILGetMatchingSymEntryByValue(
/*prev ilse*/ NIL,
/*value*/ pc,
/*wantedTypes*/ WANT_ALL_TYPES,
/*ignoredClasses*/ IGNORE_NONE,
/*numToSkip*/ 0
);
if( ilse == NIL ) goto Out;
switch( ilse->ilse_type & (~ILSE_EXT) ) {
case ILSE_PATCH:
ilseProc = ilse;
ilfe = ilse->ilse_ilfe;
goto Out;
case ILSE_MODULE:
ilseFN = ilse;
ilfe = ilse->ilse_ilfe;
goto Out;
case ILSE_TEXT:
ilseProc = ilse;
ilfe = ilse->ilse_ilfe;
break;
default:
goto Out;
}
ilse = XR_ILGetMatchingSymEntryByValue(
/*prev ilse*/ ilse,
/*value*/ 0, /* ignored */
/*wantedTypes*/ ILSE_MODULE,
/*ignoredClasses*/ IGNORE_NONE,
/*numToSkip*/ 0
);
if( (ilse != NIL)
&& (ilse->ilse_ilfe == ilseProc->ilse_ilfe)
&& ((ilse->ilse_value+ilse->ilse_size) > ilseProc->ilse_value) ) {
ilseFN = ilse;
}
Out:
if( ilseProc != NIL ) {
buf->procName = ilseProc->ilse_name;
buf->procSymID = ((unsigned)(ilseProc));
} else {
buf->procName = "";
buf->procSymID = 0;
}
if( ilfe != NIL ) {
buf->fileName = ilfe->ilfe_fName;
buf->fileSeqNum = ilfe->ilfe_seqNum;
} else {
buf->fileName = "";
buf->fileSeqNum = 0;
}
if( ilseFN != NIL ) {
ilseFN = CirioNubInnerImproveEmbeddedFileNameGuess(ilseFN);
buf->guessedEmbeddedFileName = ilseFN->ilse_name;
buf->guessedEmbeddedFileSymID = ((unsigned)(ilseFN));
} else {
buf->guessedEmbeddedFileName = "";
buf->guessedEmbeddedFileSymID = 0;
}
return 0;
}
int
CirioNubInnerGetFileEntry(seqNum, buf)
unsigned seqNum;
CirioNubFileEntry buf;
{
XR_ILFileEntry ilfe = NIL;
for(;;) {
if( (ilfe = XR_ILGetPrevFileEntry(ilfe)) == NIL )
return(-1); /* "can't hapen" */
if( ilfe->ilfe_seqNum <= seqNum ) break;
}
buf->seqNum = ilfe->ilfe_seqNum;
buf->commitPoint = ilfe->ilfe_commitPoint;
buf->fileName = ilfe->ilfe_fName;
buf->fOffset = ilfe->ilfe_fOffset;
buf->fMagic = ilfe->ilfe_fMagic;
buf->size = ilfe->ilfe_fSize;
buf->mTime = ilfe->ilfe_fMTime;
buf->sMagic = ilfe->ilfe_vMagic;
buf->stamp = ((XR_Pointer)(ilfe->ilfe_vStamp));
buf->stampSize = ilfe->ilfe_vLen;
buf->readerData = ((XR_Pointer)(ilfe->ilfe_rdrData));
buf->readerDataSize = ilfe->ilfe_rdrDataBytes;
buf->patchReloc = ((XR_Pointer)(ilfe->ilfe_pAddr));
buf->patchSize = ilfe->ilfe_pBytes;
buf->textReloc = ((XR_Pointer)(ilfe->ilfe_tAddr));
buf->textSize = ilfe->ilfe_tBytes;
buf->dataReloc = ((XR_Pointer)(ilfe->ilfe_dAddr));
buf->dataSize = ilfe->ilfe_dBytes;
buf->bssReloc = ((XR_Pointer)(ilfe->ilfe_bAddr));
buf->bssSize = ilfe->ilfe_bBytes;
buf->commonReloc = ((XR_Pointer)(ilfe->ilfe_cAddr));
buf->commonSize = ilfe->ilfe_cBytes;
return 0;
}
static void
CirioNubInnerCopySymEntry(ilse, buf)
XR_ILSymEntry ilse;
CirioNubSymEntry buf;
{
buf->symID = ((unsigned)(ilse));
buf->name = ilse->ilse_name;
buf->type = ilse->ilse_type;
buf->value = ilse->ilse_value;
buf->size = ilse->ilse_size;
buf->fileSeqNum = ilse->ilse_ilfe->ilfe_seqNum;
}
int
CirioNubInnerGetMatchingSymEntryByName(
symID, pattern, caseSensitive, wantedTypes, ignoredClasses,
numToSkip, buf
)
unsigned symID;
char *pattern;
bool caseSensitive;
unsigned wantedTypes;
unsigned ignoredClasses;
int numToSkip;
CirioNubSymEntry buf;
{
XR_ILSymEntry ilse;
ilse = XR_ILGetMatchingSymEntryByName(
((XR_ILSymEntry)(symID)),
pattern,
caseSensitive,
wantedTypes,
ignoredClasses,
numToSkip
);
if( ilse == NIL ) return (-1);
CirioNubInnerCopySymEntry(ilse, buf);
return 0;
}
int
CirioNubInnerGetMatchingSymEntryByValue (
symID, val, wantedTypes, ignoredClasses, numToSkip, buf
)
unsigned symID;
unsigned val;
unsigned wantedTypes;
unsigned ignoredClasses;
int numToSkip;
CirioNubSymEntry buf;
{
XR_ILSymEntry ilse;
ilse = XR_ILGetMatchingSymEntryByValue(
((XR_ILSymEntry)(symID)),
val,
wantedTypes,
ignoredClasses,
numToSkip
);
if( ilse == NIL ) return (-1);
CirioNubInnerCopySymEntry(ilse, buf);
return 0;
}
int
CirioNubInnerGetInstrSetAndOpSys(buf)
CirioNubInstrSetAndOpSys buf;
{
# if defined(AIX)
buf->instrSet = "RS6000";
buf->opSys = "AIX";
# elif defined(SUNOS4X)
buf->instrSet = "SPARC";
buf->opSys = "SunOS4";
# else
--> error os ? <--
# endif
return 0;
}